home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / AdobeExamples / NX_CtlPoints / ControlPointWraps.psw < prev    next >
Text File  |  1995-06-12  |  4KB  |  153 lines

  1.  
  2. /*
  3.  * (a)  (C) 1990 by Adobe Systems Incorporated. All rights reserved.
  4.  *
  5.  * (b)  If this Sample Code is distributed as part of the Display PostScript
  6.  *    System Software Development Kit from Adobe Systems Incorporated,
  7.  *    then this copy is designated as Development Software and its use is
  8.  *    subject to the terms of the License Agreement attached to such Kit.
  9.  *
  10.  * (c)  If this Sample Code is distributed independently, then the following
  11.  *    terms apply:
  12.  *
  13.  * (d)  This file may be freely copied and redistributed as long as:
  14.  *    1) Parts (a), (d), (e) and (f) continue to be included in the file,
  15.  *    2) If the file has been modified in any way, a notice of such
  16.  *      modification is conspicuously indicated.
  17.  *
  18.  * (e)  PostScript, Display PostScript, and Adobe are registered trademarks of
  19.  *    Adobe Systems Incorporated.
  20.  * 
  21.  * (f) THE INFORMATION BELOW IS FURNISHED AS IS, IS SUBJECT TO
  22.  *    CHANGE WITHOUT NOTICE, AND SHOULD NOT BE CONSTRUED
  23.  *    AS A COMMITMENT BY ADOBE SYSTEMS INCORPORATED.
  24.  *    ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY
  25.  *    OR LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO
  26.  *    WARRANTY OF ANY KIND (EXPRESS, IMPLIED OR STATUTORY)
  27.  *    WITH RESPECT TO THIS INFORMATION, AND EXPRESSLY
  28.  *    DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY, 
  29.  *    FITNESS FOR PARTICULAR PURPOSES AND NONINFRINGEMENT
  30.  *    OF THIRD PARTY RIGHTS.
  31.  */
  32.  
  33. /*
  34.  *    ControlPointWraps.psw
  35.  *
  36.  *    Version:    2.0
  37.  *    Author:    Ken Fromm
  38.  *    History:
  39.  *            03-07-91        Added this comment.
  40.  */
  41.  
  42. /*  This wrap is called in the +new method to define and bind procedures. */
  43. defineps PSWDefsContPts ()
  44.     /NOP {
  45.  
  46.     } bind def
  47.  
  48.     /SA { % x y  sa  x' y'
  49.         transform
  50.         0.25 sub round 0.25 add exch
  51.         0.25 sub round 0.25 add exch
  52.         itransform
  53.     } bind def
  54.  
  55.     /RSA { %dx dy  rsa  dx' dy'
  56.         dtransform
  57.         round exch
  58.         round exch
  59.         idtransform
  60.     } bind def
  61.  
  62.     /BRF{ %X Y
  63.         sa moveto -1.5 -1.5 rsa rmoveto  0 3 rsa rlineto
  64.         3 0 rsa rlineto 0 -3 rsa rlineto -3 0 rsa rlineto
  65.         closepath
  66.     } bind def
  67.  
  68.     /BRS{ %X Y
  69.         sa moveto -2 -2 rsa rmoveto  0 4 rsa rlineto
  70.         4 0 rsa rlineto 0 -4 rsa rlineto -4 0 rsa rlineto
  71.         closepath
  72.     } bind def
  73.     
  74.     /BX { % X Y
  75.         sa moveto -2 -2 rsa rmoveto 4 4 rsa rlineto
  76.         0 -4 rsa rmoveto -4 4 rsa rlineto
  77.     } bind def
  78.     
  79.     /BC{ % X Y
  80.         sa moveto
  81.         0 2 rsa rmoveto  0 -4 rsa rlineto
  82.         -2 2 rsa rmoveto  4 0 rsa rlineto
  83.     }  bind def
  84. endps
  85.  
  86. /* Rounds the points passed in to device space. */
  87. defineps PSWSetIndependent ( )
  88.     /sa /SA load def
  89.     /rsa /RSA load def
  90. endps
  91.  
  92. /* Does not perform any adjustment to the points. */
  93. defineps PSWSetDependent ( )
  94.     /sa /NOP load def
  95.     /rsa /NOP load def
  96. endps
  97.  
  98. defineps PSWDefineFont(char *fontname)
  99.   8 dict dup begin
  100.     /FontName /fontname def
  101.     /FontType 3 def
  102.     /FontMatrix [.001 0 0 .001 0 0] def
  103.     /FontBBox [-500 -500 500 500] def
  104.  
  105.     /Encoding 256 array def
  106.         0 1 255 {Encoding exch /.notdef put} for
  107.     
  108.     Encoding
  109.         dup (a) 0 get /Rectfill put
  110.         dup (b) 0 get /Rectstroke put
  111.         dup (c) 0 get /Ximage put
  112.         (d) 0 get /Crossstroke put
  113.     
  114.     /CharProcs 5 dict def
  115.     CharProcs begin
  116.         /.notdef { } def
  117.         /Rectfill {
  118.             -300 -300 sa moveto 0 600 rsa rlineto
  119.             600 0 rsa rlineto 0 -600 rsa rlineto closepath
  120.             fill
  121.         } def
  122.         /Rectstroke {
  123.             -400 -400 sa moveto 0 800 rsa rlineto
  124.             800 0 rsa rlineto 0 -800 rsa rlineto closepath
  125.             stroke
  126.         } def
  127.         /Ximage {
  128.             -500 -500 translate
  129.             1000 1000 scale
  130.             5 5 true [5 0 0 5 0 0] {<88 50 20 50 88>} imagemask    
  131.         } def
  132.         /Crossstroke {
  133.             0 400 sa moveto     0 -800 rsa rlineto
  134.             -400 0 sa moveto    800 0 rsa rlineto
  135.             stroke
  136.         } def
  137.     end
  138.     
  139.     /BuildChar { % font dict, char code
  140.         500 0 -750 -750 750 750 setcachedevice
  141.         exch begin
  142.             true setstrokeadjust
  143.             Encoding exch get
  144.             CharProcs exch get
  145.             exec
  146.         end
  147.     } def
  148.   end
  149.   
  150.   /fontname exch definefont pop
  151. endps
  152.  
  153.